package com.helper.dream.a361phonehelper.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.helper.dream.a361phonehelper.R;
import com.helper.dream.a361phonehelper.bean.TuijianZhiboEntity;

import java.util.List;

/**
 * Created by LamYu on 16/12/22/0022.
 */

public class TuijianZhiboAdapter extends RecyclerView.Adapter<TuijianZhiboAdapter.MyViewHolder> {
    List<TuijianZhiboEntity.DataBeanX.DataBean> data;
    Context context;
    LayoutInflater inflater;

    public TuijianZhiboAdapter(List<TuijianZhiboEntity.DataBeanX.DataBean> data, Context context) {
        this.data = data;
        this.context = context;
        inflater=LayoutInflater.from(context);
    }

    @Override
    public TuijianZhiboAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(inflater.inflate(R.layout.item_tj_zb_rv,parent,false));
    }

    @Override
    public void onBindViewHolder(TuijianZhiboAdapter.MyViewHolder holder, int position) {
        Glide.with(context).load(data.get(position).getBackground()).into(holder.iv);
        holder.tv_type.setText(data.get(position).getType()==1?"直播":"回放");
        holder.tv_author.setText(data.get(position).getAuthor());
//        holder.tv_watches.setText(data.get(position).getWatches());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        ImageView iv;
        TextView tv_type,tv_author,tv_watches;
        public MyViewHolder(View itemView) {
            super(itemView);
            iv= (ImageView) itemView.findViewById(R.id.iv_tj_zb_background);
            tv_type= (TextView) itemView.findViewById(R.id.tv_tj_zb_type);
            tv_author= (TextView) itemView.findViewById(R.id.tv_tj_zb_author);
            tv_watches= (TextView) itemView.findViewById(R.id.tv_tj_zb_watches);
        }
    }
}
